package sistema;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import javax.imageio.ImageIO;


public class PegaImagem {

	private static BufferedImage imagem;

	/**
	 * @param args
	 */
	public static BufferedImage getImagem(String urlImagem) {
		try {  
            
            final int BUFFER_SIZE = 95 * 95;  
            
            URL url = new URL(urlImagem);  
          
            BufferedInputStream stream = new BufferedInputStream(  
                    url.openStream(), BUFFER_SIZE);  
            
            File image = new File(stream + ".png");
            imagem = ImageIO.read(image);
            
        } catch (MalformedURLException e1) {  
            // TODO Auto-generated catch block  
            e1.printStackTrace();  
        } catch (Exception e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }
		return imagem;
	}

}
